home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
dskut
/
wd.zip
/
WDFMT.C
< prev
next >
Wrap
Text File
|
1987-11-23
|
35KB
|
1,087 lines
/*************************************/
/* */
/* */
/* */
/*************************************/
/*
Western Digital Corp. Format Routine
Author: Dave Evans
Edited by Tom Devlin
Creation Date: 08/08/86
Revision Date: 7/23/87
Revision: 2.10
Formats drive based on #cylinders, #heads, #sectors, and
interleave entered at command line or on screen. Does low-level format
followed by a Read-verify of the entire drive. Shows errors
detected, then allows user to enter additional blocks to
format with bad block marks. The program may be aborted
with an Escape at both the Format prompt and at the Format
Bad Block prompt.
Rev. 1.01 dle
Added ability to format drive D:, and also the ability to
specify the precomp cylinder.
New command line format:
WDFMT drive #cyls #heads #sectors interleave precomp-cyl
Rev.2.00 thd
Added ability to format up to 16 heads.
fix to enable format of drive 1.
New drive spec enrty by screen:
Rev.2.10 thd
Added Surface test, Skew, Alt sector, and made the program menu
driven. Surface test does just that. Skew is the diferance in
sector numbers on adjacent heads. Alt sector when enabled will
format an extra sector to be used in the verify if a bad sector
is found. The user can enter drive parameters on the DOS command
line or in the program.
New command line format:
WDFMT drive #cyls #heads #sectors interleave precomp-cyl skew
*/
#include <\c_ms\include\dos.h>
#include <\c_ms\include\stdio.h>
#include <\c_ms\include\ctype.h>
#include <\c_ms\include\math.h>
#include <\c_ms\include\limits.h>
#include <\c_ms\include\scancode.h>
#include <\c_ms\include\color.h>
#include <\c_ms\include\structs.h>
#include <\c_ms\include\defs.h>
/* Global variables:
Command parser modifies the tables, and global flags
indicate to the Main routine the requested action.
*/
struct type_htable hd_table;
struct type_task_file task_file;
struct type_esfile;
union REGS inregs, outregs;
union type_scan scan_code;
struct type_error err_table[300];
char *rd_buffer, *wr_buffer, *fmt_buffer;
char head_buff[16][buf_length];
int command, err_count, errcnt, bad_count, redirection, head;
unsigned char alt_value =00; /* this is the sector # of the alt sector */
/******************************************/
/******************************************/
/******************************************/
/******************************************/
main(argc, argv)
int argc;
char *argv[];
{
char *malloc();
wr_buffer = malloc(buf_length);
rd_buffer = malloc(buf_length);
fmt_buffer = malloc(buf_length);
/*************************************/
/* */
/* start of main body */
/* */
/*************************************/
hd_table.sec_number = 1; /*initialize hd_table to defalt*/
hd_table.blk_size = 1;
hd_table.max_cyl = 615;
hd_table.max_head = 4;
hd_table.max_sec = 17;
hd_table.precomp = 306;
hd_table.retry = 0;
hd_table.step = 0;
hd_table.ileave = 3;
hd_table.drv_number = 0;
hd_table.skew = 0;
hd_table.alt_sector = 0;
hd_table.ecc = 1; /* set for ecc in SDH reg */
hd_table.sec_size = 0x01; /* 01 for 512 bytes/sector */
redirection = FALSE; /* set redirection of input to false */
get_spec(argc, argv); /* get specs from dos command line */
screen_update(); /* out put screen */
get_2spec(); /* get drive specs from screen */
hd_table.max_cyl--; /* adjust table values */
hd_table.max_head--;
hd_table.precomp = (int)((hd_table.precomp + 3)/4); /* ajust precomp */
for(head=0; head<=hd_table.max_head; head++)
do_ilt(0,head,&head_buff[head][0]);/* set up interleave for good blocks */
if(hd_table.alt_sector)
hd_table.blk_size = hd_table.max_sec - 1;
else
hd_table.blk_size = hd_table.max_sec;
command =0;
while(TRUE)
{ /* start of main while loop */
display_menue(); /* put menue up on screen */
command = get_command(); /* get command on what to do */
do_command(command); /* do that command */
} /* end of main while loop */
} /* end of main body */
/*************************************/
/* */
/* eend of main body */
/* */
/*************************************/
/*************************************/
/* */
/* display_menue() */
/* */
/* put menue on screen */
/* */
/*************************************/
display_menue()
{ /* start of display_menue */
upscroll(11,13,24,0,79,VNORMAL); /* clear portion of screen */
print_atrb(13,20+h_shift," ENTER MENU CHOICE",VNORMAL);
print_atrb(15,20,"F",INVERSE); /* print high light "F" */
print_atrb(15,21,"ormat disk CAUTION this will destroy all data on drive !",VNORMAL); /* print rest of format */
print_atrb(17,20,"V",INVERSE); /* print high light "V" */
print_atrb(17,21,"erify disk",VNORMAL); /* print rest of Verify */
print_atrb(19,20,"B",INVERSE); /* print high light "V" */
print_atrb(19,21,"ad sector entry",VNORMAL);/* print rest of Verify */
print_atrb(21,20,"S",INVERSE); /* print high light "S" */
print_atrb(21,21,"urface test CAUTION this will destroy all data on drive !",VNORMAL); /* print rest of Surface test */
print_atrb(23,20,"Q",INVERSE); /* print high light "Q" */
print_atrb(23,21,"uit",VNORMAL); /* print rest of Quit */
} /* end of display menue */
/*************************************/
/* */
/* get_command() */
/* */
/* output : command value */
/* */
/*************************************/
int get_command()
{ /* start of get_command() */
int done,old_command;
char prompt_row;
unsigned char temp_ch;
done = FALSE;
prompt_row = 15;
old_command = command;
curs(prompt_row+(2*command),18);ARROW; /* print arrow */
curs(prompt_row+(2*command),20);
while(!done)
{ /* start of while */
temp_ch = get_input(redirection); /* get input */
temp_ch = toupper(temp_ch);
switch(temp_ch)
{ /* start of switch */
case 'F' : old_command = command;
command = 0; /* format */
break;
case 'V' : old_command = command;
command = 1; /* verify */
break;
case 'B' : old_command = command;
command = 2; /* bad track */
break;
case 'S' : old_command = command;
command = 3; /* surface */
break;
case 'Q' : old_command = command;
command = 4; /* quit */
break;
case CURUP : old_command = command;
if(command EQL 0) command = 4; /* up arrow */
else --command;
break;
case CURDN : old_command = command;
if(command EQL 4) command = 0; /* down arrow */
else ++command;
break;
case CRG_RTN: done = TRUE; /* a <CR> was hit */
break;
default : BELL;
} /* end of switch */
curs(prompt_row+(2*old_command),18);BLANK_SP;
curs(prompt_row+(2*command),18);ARROW; /* print arrow */
curs(prompt_row+(2*command),20);
} /* end of while */
return command; /* return command */
} /* end of get_command() */
/*************************************/
/* */
/* do_command(command) */
/* */
/* input : command */
/* */
/* do the command defined by command*/
/* */
/*************************************/
do_command(command)
int command;
{ /* start of do_command */
switch(command)
{ /* start of switch */
case 0 : do_format();break; /* format disk */
case 1 : do_verify();break; /* verify disk */
case 2 : do_bad_track(